package bandidong.bean;

import bandidong.dao.AdminDAO;
import bandidong.dao.impl.AdminDAOImpl;
import bandidong.model.Admin;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
@TransactionManagement(javax.ejb.TransactionManagementType.CONTAINER) 
public class AdminBean implements AdminBeanRemote {
    
    @PersistenceContext(unitName = "persistenceUnit")
    EntityManager em;
    
    private AdminDAO adminDAO = null;
    
    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public String checkExists(Admin admin) {
        adminDAO = new AdminDAOImpl(em);
        return adminDAO.checkExists(admin);
    }

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public String updateAdmin(Admin admin) {
        adminDAO = new AdminDAOImpl(em);
        return adminDAO.updateAdmin(admin);
    }
}
